import 'package:flutter/material.dart';

import '../../app/res/app_color.dart';

/// * 作者: Tao
/// * 日期: 2025/11/6
/// * 时间: 14:17
/// * 描述: 商品横向展示控件
class CommonProductHorizontalWidget extends StatelessWidget {
  /// 商品图片链接
  final String imageUrl;

  /// 商品标题
  final String title;

  /// 商品描述
  final String content;

  /// 商品价格
  final int price;

  /// 构造函数
  /// * [imageUrl] 商品图片链接
  /// * [title] 商品标题
  /// * [content] 描述
  /// * [price] 价格
  const CommonProductHorizontalWidget(
      {Key? key,
      required this.imageUrl,
      required this.title,
      required this.content,
      required this.price})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 140.0,
      child: Container(
        decoration: BoxDecoration(
          color: AppColor.white,
          borderRadius: BorderRadius.all(Radius.circular(5.0)),
          boxShadow: [
            BoxShadow(
              color: AppColor.grey ?? Colors.grey,
              offset: Offset(0.0, 0.5),
              blurRadius: 5.0,
              spreadRadius: 1.0,
            )
          ],
        ),
        child: Padding(
          padding: EdgeInsets.all(12.0),
          child: Row(
            children: [
              Image.network(width: 100.0, height: 150.0, imageUrl, fit: BoxFit.contain),
              Spacer(),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  // 商品名称
                  SizedBox(
                    width: 160.0,
                    child: Text(title,
                        style: TextStyle(fontSize: 13.0),
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis),
                  ),
                  SizedBox(height: 6.0),
                  // 描述
                  SizedBox(
                    width: 160.0,
                    child: Text(content,
                        style: TextStyle(fontSize: 10.0, color: AppColor.grey500),
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis),
                  ),
                  SizedBox(height: 10.0),
                  Text('￥$price', style: TextStyle(fontSize: 10.0, color: AppColor.red600)),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
